﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data.Linq;
using System.Data.SqlClient;
using Website.Logger;

namespace UILGestion.Admin
{
    public partial class TipoCambioListForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                try
                {

                    //idObra.Value = (string)Request.QueryString["idObra"];
                    menuCtrl1.loadMenuAdmin();
                    FormatForm();


                }
                catch (SqlException sqlex)
                {
                    WebServerSideSqlError.Log(sqlex);

                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                     "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


                }
                catch (Exception ex)
                {
                    WebServerSideError.Log(ex);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                         "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

                }

            }
        }
        private void Find()
        {
            //dbGestionDataContext _db;

            //_db =
            //    new dbGestionDataContext(Parametros.strConnString);

            //(DD/MM/yyyy)
            System.IFormatProvider MiFp =
                                                        new System.Globalization.
                                                        CultureInfo("es-ES", false);
            //valores de parametro

            //var q = from i in _db.view_TipoCambio
            //        select i;

           
            //proveedorGridView.DataSource = q.OrderByDescending(p=>p.fecha);
            //proveedorGridView.DataBind();
        }
        private void FormatForm()
        {
            
            //restricionesForm();
            Find();
            //estadistica();

            string Lang = "es-ES";  //para controlar el idioma 
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo
   (Lang);

            //ImportPresupuestoLinkButton.OnClientClick =
            //    WindowPresupuesto.GetShowReference("../Admin/PresuImportForm.aspx", "Importacion Presupuesto");
        }
        
        protected void actualizarButton_Click(object sender, EventArgs e)
        {
            try
            {
               // Find();
            }
            catch (SqlException sqlex)
            {
                WebServerSideSqlError.Log(sqlex);

                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


            }
            catch (Exception ex)
            {
                WebServerSideError.Log(ex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                     "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

            }
        }

        protected void nuevoButton_Click(object sender, EventArgs e)
        {
            try
            {
                Response.Redirect("TipoCambioEditForm.aspx", true);
            }
            catch (SqlException sqlex)
            {
                WebServerSideSqlError.Log(sqlex);

                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


            }
            catch (Exception ex)
            {
                WebServerSideError.Log(ex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                     "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

            }
        }

      
        
    }
}